package com.zkt.oss.controller;

import com.zkt.oss.constants.FileConstant;
import com.zkt.oss.entity.Result;
import com.zkt.oss.service.FileService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 赵开泰
 * @program jc-club
 * @date 2025/3/17 21:53
 * @description 文件相关controller
 **/

@RestController
@RequestMapping("/file")
public class FileController {
	
	@Resource
	private FileService fileService;
	
	/**
	 * 上传头像
	 *
	 * @param file 头像图片文件
	 * @return 文件路径
	 */
	@PostMapping("uploadAvatar")
	public Result<String> uploadAvatar(@RequestParam("file") MultipartFile file) {
		if (file.isEmpty()) {
			return Result.fail("文件为空");
		}
		
		return Result.ok(fileService.uploadAvatar(file));
	}
	
}